﻿using H2.NET.Common;
using H2.NET.Web.Pages.SMD.Service;
using H2.NET.Web.Workflow.DwzCode;
using H2.NET.Web.Workflow.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace H2.NET.Web.Management.MeiPing
{
    public partial class Index : BasePage
    {
        private readonly MeiPingService _mpService = new MeiPingService();
        public string SerialNumber;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (AksRequest.GetQueryString("action") == "delete")
            {
                _mpService.Delete(AksRequest.GetFormInt("id"));

                SuccessMsg("MeiPingIndex");
                return;
            }

            string strWhere = "1=1";
            if (!string.IsNullOrEmpty(Request.Form["SerialNumber"]))
            {
                strWhere += " and SerialNumber like '%" + Request.Form["SerialNumber"].Trim() + "%'";
            }

            TotalItemCount = _mpService.GetRecordCount(strWhere);
            PageNumber = Convert.ToInt32(Request.Form["pageNum"] ?? "1");

            Pager1.TotalItemCount = TotalItemCount;
            Pager1.PageSize = PageSize;
            Pager1.PageNumber = PageNumber;
            rpt_mps.DataSource = _mpService.GetListByPage(strWhere, "",
                                                              PageSize * (PageNumber - 1) + 1,
                                                              PageSize * PageNumber);
            rpt_mps.DataBind();


            SerialNumber = Request.Form["SerialNumber"];
        }
    }
}